export default {
    // mutations 就是为了改变state里面的状态值,做一些单一的操作,复杂的异步的操作放在actions里面进行
    // 商品数量加一功能
    addcounter(state, payload) {
        payload.count++
        localStorage.setItem('productlist', JSON.stringify(state.productlist))
    },
    // 添加新商品功能
    toadd(state, payload) {
        state.productlist.push(payload)
        localStorage.setItem('productlist', JSON.stringify(state.productlist))
    },
    // 商品数量加一功能
    add1(state, payload) {
        payload.count++
        localStorage.setItem("productlist", JSON.stringify(state.productlist)
        );
    },
    // 商品数量减一功能
    remove1(state, payload) {
        payload.count--
        localStorage.setItem("productlist", JSON.stringify(state.productlist)
        );
    },
    // 删除商品功能
    delete1(state, payload) {
        state.productlist.splice(payload, 1);
        localStorage.setItem("productlist", JSON.stringify(state.productlist)
        );
    }
}
